package com.cys.dm.rabbitService;

import com.cys.dm.client.scheduler.DmSchedulerSeatClient;
import com.cys.dm.entity.scheduler.DmSchedulerSeat;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author blue_t
 * @date 2020-12-27 15:20
 */
@RabbitListener(queues = {"dm-scheduler-seat-back"})
@Component
public class DmSchedulerSeatRabbitBack {
    @Autowired
    private DmSchedulerSeatClient dmSchedulerSeatClient;

    /**
     * 座位状态回滚
     * @param list 要回滚的数据
     */
    @RabbitHandler
    public void schedulerSeatRollback(List<DmSchedulerSeat> list){
        list.forEach(x->{
            dmSchedulerSeatClient.updateSeatByXAndYAndScheduleId(x);
        });
        System.out.println("座位状态被回滚了-----------");
    }
}
